package com.example.baidu;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

	private WebView w;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        w  = (WebView) findViewById(R.id.web);
        WebSettings set = w.getSettings();
        set.setJavaScriptEnabled(true);
        set.setDomStorageEnabled(true);
        w.loadUrl("https://m.baidu.com");
        w.setWebViewClient(new WebViewClient());
    }
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	     if(keyCode == event.KEYCODE_BACK){
	    	 if(w.canGoBack()){
	    		 w.goBack();
	    		 return true;
	    	 }
	     }
		return super.onKeyDown(keyCode, event);
	}
    
    
}
